<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title></title>

    <meta name="keywords" content="{$Think.CONFIG.keywords}"/>
    <meta name="description" content="{$Think.CONFIG.description}"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

    {include file="public/head" /}

</head>
<body>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>
        {include file="public/nav"/}


        {include file="public/menu"/}

        <div class="main-content">
            {include file="public/breadcrumb"/}

            <div class="page-content">
                <div class="row">
                    <div class="cf">
                        <!--<a class="btn btn-info" href="{:Url('addFront')}">新增</a>-->
                        <!--数据筛选表单-->
                        <form class="form-inline fmWorkQuery-hook">
                            <input class="input-small" name="num" placeholder="工单号"/>
                            <input class="input-large" name="car_num" placeholder="车牌号"/>
                            <input class="input-small" name="client_name" placeholder="客户姓名"/>
                            <button type="button" class="btn btn-info btn-sm" onclick="index.search();">
                                <i class="fa fa-search bigger-110"></i>
                                查找
                            </button>
                            <button type="button" class="btn btn-primary btn-sm" onclick="index.searchNull();">
                                <i class="fa fa-remove bigger-110"></i>
                                清空
                            </button>
                        </form>
                    </div>

                    <div class="space-4"></div>

                    <table id="tbWork"></table>
                    <div id="tbWorkPager"></div>

                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->

    </div><!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="fa fa-angle-double-up fa-only bigger-110"></i>
    </a>
</div>
</body>
{include file="public/footerjs"/}

<script>

    (function () {
        $(function () {
            //加载数据
            var $tbWork = $('#tbWork'), $pager = $('#tbWorkPager');
            $tbWork.jqGrid({
                url: '{:url("work/getWorkServer")}',
                datatype: 'json',
                mttype: 'post',
                colNames: ['工单号', '车牌号', '日期', '客户', '接待人', '维修技师', '消费金额', '是否已结', '操作'],
                colModel: [
                    {name: 'num', index: 'num', width: '100', align: 'center'},
                    {name: 'car_num', index: 'car_num', width: '100', align: 'center'},
                    {
                        name: 'date', index: 'date', width: '100', align: 'center',
                        formatter: function (value, options, obj) {
                            return value.substr(0, 10);
                        }
                    },
                    {name: 'client_name', index: 'client_name', width: '100', align: 'center'},
                    {name: 'reception_name', index: 'reception_name', width: '100', align: 'center'},
                    {name: 'repairman_name', index: 'repairman_name', width: '100', align: 'center'},
                    {name: 'total', index: 'total', width: '100', align: 'center'},
                    {
                        name: 'pay_result', index: 'pay_result', width: '100', align: 'center',
                        formatter: function (value, options, obj) {
                            return value == 1 ? '已结' : '<span style="color:red;">未结</span>';
                        }
                    },
                    {
                        name: 'id', index: 'id', width: '100', align: 'center',
                        formatter: function (value, options, obj) {
                            return '<a onclick="index.del(' + value + ')" style="cursor:pointer;">删除</a>&nbsp;&nbsp;<a href="/admin/invoice/index/id/' + value + '" target="_blank" style="cursor:pointer;">详情</a>';
                        }
                    },
                ],
                height: 'auto',
                pager: '#tbWorkPager',
                viewrecords: true,
                rowNum: 10,
                rowList: [10, 20, 40],
                autowidth: true
            });
            // 隐藏水平方向滚动条
            $tbWork.closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        });
        index = {
            search: function () {
                var $fmQuery = $('.fmWorkQuery-hook');
                var param = ittaoli.serializeObject($fmQuery);
                $('#tbWork').jqGrid('setGridParam', {
                    postData: {q: JSON.stringify(param)},
                    page: 1
                }).trigger("reloadGrid");
            },
            searchNull: function () {
                $('.fmWorkQuery-hook input').val('');
                var param = {};
                $('#tbWork').jqGrid('setGridParam', {
                    postData: {q: JSON.stringify(param)},
                    page: 1
                }).trigger("reloadGrid");
            },
            del: function (id) {
                bootbox.confirm("确定要删除该条工单？", function (result) {
                    if (result) {
                        $.post("{:url('del')}", {id: id}, function (data) {
                            if (data > 0) {
                                bootbox.alert("删除成功");
                                index.search();
                            } else {
                                bootbox.alert("删除失败");
                            }
                        })
                    }
                })
            }
        }
    }());
</script>

{include file="public/foot" /}
